package szwolaiyun.paireach.com.szwolaizhuang.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RelativeLayout;

import com.paireach.szwolaiyun.sz_common_widget.fragment.BaseFragment;
import com.paireach.szwolaiyun.sz_util.SharedPreferencesUtil;

import szwolaiyun.paireach.com.szwolaizhuang.R;
import szwolaiyun.paireach.com.szwolaizhuang.activity.ChangePasswordActivity;
import szwolaiyun.paireach.com.szwolaizhuang.activity.LoginActivity;


public class PersonalCenterFragment extends BaseFragment implements View.OnClickListener {

    private View view;
    private Button logout;
    private RelativeLayout rl_changepsw;

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_personal_center, null);
        initControl();
        return view;
    }

    private void initControl() {
        logout = (Button) view.findViewById(R.id.bt_logout);
        rl_changepsw = (RelativeLayout) view.findViewById(R.id.rl_changepsw);
        rl_changepsw.setOnClickListener(this);
        logout.setOnClickListener(this);
        view.findViewById(R.id.layout_top_back).setVisibility(View.GONE);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.bt_logout:
                SharedPreferencesUtil.setValue(getActivity(), SharedPreferencesUtil.USER_NAME,"");
                SharedPreferencesUtil.setValue(getActivity(), SharedPreferencesUtil.REAL_NAME,"");
                SharedPreferencesUtil.setValue(getActivity(), SharedPreferencesUtil.ID,"");
                startActivity(new Intent(getActivity(), LoginActivity.class));
                getActivity().finish();
                break;
            case R.id.rl_changepsw:
                startActivity(new Intent(getActivity(), ChangePasswordActivity.class));
                break;
        }
    }
}
